<script setup>
import { defineProps, defineEmits } from 'vue';

const props = defineProps({
  activeSection: {
    type: String,
    required: true
  },
  avatar: {
    type: String,
    default: ''
  }
});

const emit = defineEmits(['update:activeSection', 'avatar-upload']);

const setActiveSection = (section) => {
  emit('update:activeSection', section);
};

const handleAvatarUpload = () => {
  emit('avatar-upload');
};
</script>

<template>
  <div class="profile-sidebar">
    <div class="profile-avatar">
      <div class="avatar-icon" v-if="avatar" :style="{ backgroundImage: `url(${avatar})` }">
      </div>
      <div class="avatar-icon" v-else>
        <i class="fas fa-user"></i>
      </div>
      <button class="change-avatar-btn" @click="handleAvatarUpload">更换头像</button>
    </div>
    
    <div class="profile-menu">
      <div 
        class="menu-item" 
        :class="{ 'active': activeSection === 'profile' }"
        @click="setActiveSection('profile')"
      >
        <i class="fas fa-user"></i>
        <span>个人资料</span>
      </div>
      <div 
        class="menu-item" 
        :class="{ 'active': activeSection === 'security' }"
        @click="setActiveSection('security')"
      >
        <i class="fas fa-shield-alt"></i>
        <span>账户安全</span>
      </div>
      <div 
        class="menu-item" 
        :class="{ 'active': activeSection === 'notifications' }"
        @click="setActiveSection('notifications')"
      >
        <i class="fas fa-bell"></i>
        <span>通知设置</span>
      </div>
    </div>
  </div>
</template>

<style scoped>
.profile-sidebar {
  width: 280px;
  background-color: #f8f9fa;
  padding: 30px 0;
  border-right: 1px solid #eee;
}

.profile-avatar {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 30px;
  padding: 0 20px;
}

.avatar-icon {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background-color: #e0e0e0;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 15px;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.1);
  border: 3px solid #ffffff;
  transition: all 0.3s ease;
  background-size: cover;
  background-position: center;
}

.avatar-icon i {
  font-size: 60px;
  color: #999999;
}

.avatar-icon:hover {
  transform: scale(1.05);
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.15);
}

.change-avatar-btn {
  padding: 8px 16px;
  border: none;
  background-color: #fff;
  color: #00c389;
  border-radius: 20px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.3s ease;
  border: 1px solid #00c389;
}

.change-avatar-btn:hover {
  background-color: #00c389;
  color: #fff;
}

.profile-menu {
  display: flex;
  flex-direction: column;
}

.menu-item {
  display: flex;
  align-items: center;
  padding: 15px 30px;
  cursor: pointer;
  transition: all 0.3s ease;
  position: relative;
  color: #555;
}

.menu-item:hover,
.menu-item.active {
  background-color: #f0f9f6;
  color: #00c389;
}

.menu-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background-color: #00c389;
}

.menu-item i {
  margin-right: 15px;
  font-size: 1.1rem;
  width: 20px;
  text-align: center;
}

@media (max-width: 992px) {
  .profile-sidebar {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid #eee;
    padding: 20px;
  }
  
  .profile-menu {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
  }
  
  .menu-item {
    padding: 10px 15px;
    border-radius: 8px;
  }
  
  .menu-item.active::before {
    display: none;
  }
  
  .menu-item.active {
    background-color: #00c389;
    color: white;
  }
}
</style> 